home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Grafik & Text & Film / Quark XTensions / Freeware Xtensions / Scripts folder / Scripts / Guides • Guides to box 1.7-Text < prev    next >
Text File  |  1994-04-11  |  4KB  |  95 lines

  1. tell application "QuarkXPress®"
  2.     activate
  3.     
  4.     try
  5.         --this script is meant to run with version 3.3. Version 3.2 will place the guides one point off
  6.         --a slight bug that was corrected in 3.3, aren't you glad the Quark folks are on top of things?
  7.         set QuarkVersion to version as text
  8.         if QuarkVersion is not "3.3" then
  9.             display dialog "This script was designed to run with version 3.3 of QuarkXPress. " & return & ¬
  10.                 "Using another version might not produce the proper results." buttons {"Cancel", "Try Anyway"} default button 1
  11.         end if
  12.         
  13.         --we have to check for an existing document
  14.         if exists document 1 then
  15.             --this activates the routine at the bottom which looks for a single active box
  16.             --if the routine sends back an error this if statement stops
  17.             --if it sends back a true it continues
  18.             if my CheckForSingleBox() is true then
  19.                 
  20.                 --give the document to change its measurement sytem to points because
  21.                 --we'll be using points to figure the box boundries
  22.                 tell document 1
  23.                     set hm to horizontal measure
  24.                     set vm to vertical measure
  25.                     set horizontal measure to points
  26.                     set vertical measure to points
  27.                     
  28.                     --in order to place guides we have to know which page the box is on
  29.                     --an easy way is to give a show command to the box and then show the page
  30.                     --this makes the box appear in the upper left corner of the screen
  31.                     show current box
  32.                     show current page
  33.                     set pagenumber to the index of current page
  34.                     
  35.                     --this get the bounds of the current box in points
  36.                     --bounds are measured from the top and left of the page
  37.                     --A is down from the top of the page to the top left box handle
  38.                     --B is from the left of the page to top left box handle
  39.                     --C  is from the top of the page to the bottom right box handle
  40.                     --D is from the left of the page to the bottom right box handle
  41.                     set boxBounds to bounds of current box as list
  42.                     set a to ((item 1 of boxBounds) as points) as real
  43.                     set b to ((item 2 of boxBounds) as points) as real
  44.                     set C to ((item 3 of boxBounds) as points) as real
  45.                     set D to ((item 4 of boxBounds) as points) as real
  46.                 end tell
  47.                 
  48.                 --now we tell the page to make the guides. These are page guides
  49.                 --not spread guides which go across both pages and pasteboard
  50.                 tell page pagenumber of document 1
  51.                     make horizontal guide at beginning with properties {position:a}
  52.                     make vertical guide at beginning with properties {position:b}
  53.                     make horizontal guide at beginning with properties {position:C}
  54.                     make vertical guide at beginning with properties {position:D}
  55.                 end tell
  56.                 
  57.                 --set the measurement system back to what it was
  58.                 tell document 1
  59.                 beep
  60.                     set horizontal measure to hm
  61.                     set vertical measure to vm
  62.                 end tell
  63.             end if
  64.         else
  65.             beep 2
  66.             display dialog "There is no document currently open!" buttons {"Ooops!"} default button 1 with icon 0
  67.         end if
  68.         --in case of an error a dialog with the error is posted
  69.     on error errtext number errnum
  70.         display dialog errtext buttons {"OK"} default button 1
  71.     end try
  72. end tell
  73.  
  74.  
  75. --this routine checks for a single text or picture box that is active
  76. --if no box is active it will error and post the dialog
  77. --if more than one box is active, the active boxes will be thought of by
  78. --XPress as a group and will report a class of group, which will error
  79. --if a line is active (XPress considers lines to be boxes) it will post an error
  80. --it will only return a true if there is a single text or picture box selected
  81. on CheckForSingleBox()
  82.     tell document 1 of application "QuarkXPress®"
  83.         try
  84.             if class of current box is in {picture box, text box} then
  85.                 return true
  86.             else
  87.                 error
  88.             end if
  89.         on error
  90.             beep
  91.             display dialog "A single text or picture box must be selected to run this script." buttons {"OK"} default button 1
  92.             return false
  93.         end try
  94.     end tell
  95. end CheckForSingleBox